package fitnesshub.controller;

import fitnesshub.pojo.vo.statistics.*;
import fitnesshub.result.Result;
import fitnesshub.service.StatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 统计报表
 */
@RestController
@RequestMapping("/admin/statistics")
@Slf4j
public class StatisticsController {

    @Autowired
    private StatisticsService statisticsService;

    /**
     * 获取仪表盘数据
     */
    @GetMapping("/dashboard")
    public Result<DashboardVO> getDashboardData() {
        log.info("获取仪表盘数据");
        DashboardVO dashboardVO = statisticsService.getDashboardData();
        return Result.success(dashboardVO);
    }

    /**
     * 获取会员类型分布数据
     */
    @GetMapping("/member-type-distribution")
    public Result<List<MemberTypeDistributionVO>> getMemberTypeDistribution() {
        log.info("获取会员类型分布数据");
        List<MemberTypeDistributionVO> memberTypeDistributionList = statisticsService.getMemberTypeDistribution();
        return Result.success(memberTypeDistributionList);
    }

    /**
     * 获取课程销量数据
     */
    @GetMapping("/course-sales")
    public Result<List<CourseSalesVO>> getCourseSales() {
        log.info("获取课程销量数据");
        List<CourseSalesVO> courseSalesVO = statisticsService.getCourseSales();
        return Result.success(courseSalesVO);
    }

    /**
     * 获取课程收入数据
     */
    @GetMapping("/course-revenue")
    public Result<List<CourseRevenueVO>> getCourseRevenue() {
        log.info("获取课程收入数据");
        List<CourseRevenueVO> courseRevenueVO = statisticsService.getCourseRevenue();
        return Result.success(courseRevenueVO);
    }

    /**
     * 获取消费类型分布数据
     */
    @GetMapping("/consumption-type-distribution")
    public Result<List<ConsumptionTypeDistributionVO>> getConsumptionTypeDistribution() {
        log.info("获取消费类型分布数据");
        List<ConsumptionTypeDistributionVO> consumptionTypeDistributionList = statisticsService.getConsumptionTypeDistribution();
        return Result.success(consumptionTypeDistributionList);
    }

    /**
     * 获取会员消费排行榜数据
     */
    @GetMapping("/consumption-ranking")
    public Result<List<ConsumptionRankingVO>> getConsumptionRanking() {
        log.info("获取会员消费排行榜数据");
        List<ConsumptionRankingVO> consumptionRankingList = statisticsService.getConsumptionRanking();
        return Result.success(consumptionRankingList);
    }

    /**
     * 获取设备状态分布数据
     */
    @GetMapping("/equipment-status-distribution")
    public Result<List<EquipmentStatusDistributionVO>> getEquipmentStatusDistribution() {
        log.info("获取设备状态分布数据");
        List<EquipmentStatusDistributionVO> equipmentStatusDistributionList = statisticsService.getEquipmentStatusDistribution();
        return Result.success(equipmentStatusDistributionList);
    }

    /**
     * 获取设备类型分布数据
     */
    @GetMapping("/equipment-type-distribution")
    public Result<List<EquipmentTypeDistributionVO>> getEquipmentTypeDistribution() {
        log.info("获取设备类型分布数据");
        List<EquipmentTypeDistributionVO> equipmentTypeDistributionList = statisticsService.getEquipmentTypeDistribution();
        return Result.success(equipmentTypeDistributionList);
    }

    /**
     * 获取教练性别分布数据
     */
    @GetMapping("/coach-gender-distribution")
    public Result<List<CoachGenderDistributionVO>> getCoachGenderDistribution() {
        log.info("获取教练性别分布数据");
        List<CoachGenderDistributionVO> coachGenderDistributionList = statisticsService.getCoachGenderDistribution();
        return Result.success(coachGenderDistributionList);
    }

    /**
     * 获取教练年龄分布数据
     */
    @GetMapping("/coach-age-distribution")
    public Result<List<CoachAgeDistributionVO>> getCoachAgeDistribution() {
        log.info("获取教练年龄分布数据");
        List<CoachAgeDistributionVO> coachAgeDistributionVO = statisticsService.getCoachAgeDistribution();
        return Result.success(coachAgeDistributionVO);
    }
}
